﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Lead2012.Business;
using Lead2012.Models;
using Lead2012.ViewModels;
using Lead2012.Repository;

namespace Lead2012.Controllers
{
    public class ChangeSettingsController : BaseController
    {
        // Create an instance of repository
        SettingManagementRepository repository = new SettingManagementRepository();

        [Authorize(Roles = "Administrator")]
        public ActionResult Index()
        {
            SettingViewModel model = new SettingViewModel();

            // Setup model
            model.PageType = "Menu";
            SetupCommon(model, string.Empty, "Name");
            repository.GetModel(model);

            return View(model);
        }

        [HttpPost]
        public ActionResult UpdateSetting(List<FieldSystemItem> UpdateSetting)
        {
            try
            {
                repository.UpdateSettings(UpdateSetting);
            }
            catch
            {
            }

            return Json(string.Empty, JsonRequestBehavior.AllowGet);
        }
    }
}
